<template>
	<view>
		<view class="bg1 relative u-page">
			<image class="bgImg" :src="`${resources.myTopBg}`" mode=""></image>
			<view class="relative  scrollView" style="z-index: 10;">
				<uni-nav-bar :statusBar="true" :border="false" :background-color="'transparent'"
					title="我的"></uni-nav-bar>
				<view class="flex alg-center pL15">
					<u-image  :mode="'aspectFit'" :width="120" :borderRadius="20" :height="120" v-if="userInfo.headSculpturePath"
						class="myHeader" :src="xf.getImgUrl(userInfo.headSculpturePath)" mode=""></u-image>
					<image  v-else class="myHeader" :src="resources.defaultHeader" mode=""></image>
					<view class="mL10" style="width: calc(100% - 140rpx);">
						<view class="pR15">
							<text class="font18 bold">{{userInfo.nickname||userInfo.comName}}</text>
							<text @click="xf.onlineUtils.route(`/pages/common/myLevel/index`)" class="u-org bold pL5 font16 qx">{{userInfo.level}}</text>
						</view>
						<view class="font15 u-8bd mT5 flex alg-center jst-between">
							<view class="flex alg-center">
								<block v-if="authStatusInfo.authStatus==0">
									<view class="noRz">
										<text
											@click="xf.onlineUtils.route('/pages/companyPage/subpackge/my/smrz/smrz')">去认证</text>
										<u-icon name="arrow-right"></u-icon>
									</view>
								</block>
								<block v-else>
									<block v-if="authStatusInfo.authStatus==1">
										<text class="pL5">企业招工认证</text>
										<image class="w24 mL5" :src="resources.qyrzLogo" mode=""></image>
									</block>
									<block v-else>
										<text class="pL5">个人招工认证</text>
										<image class="w24 mL5" :src="resources.grrzLogo" mode=""></image>
									</block>
									<image :src="resources.star" class="imgW24 mL10" mode=""></image>
									<text class="u-org mL5">{{userInfo.score}}</text>
								</block>
							</view>
							<view class="myZlBox flex alg-center"
								@click="editPage">
								<image class="zlImg" :src="resources.editMyinfo" mode=""></image>
								<text class="font13">我的资料</text>
							</view>
						</view>
					</view>
				</view>
				<view class="walletInfo  flex alg-center">
					<view class="w33" @click="xf.onlineUtils.route('pages/common/myGrade/index')">
						<view class="font20 t-center">{{userInfo.count?userInfo.count:0}}</view>
						<view class="t-center font13 u-6">我的积分</view>
					</view>
					<view class="w33" @click="xf.onlineUtils.route('pages/companyPage/subpackge/my/myPublish/index')">
						<view class="font20 t-center">{{userInfo.onlinePosition||0}}</view>
						<view class="t-center font13 u-6">在线职位</view>
					</view>

					<view class="w33" @click="editPage">
						<view class="t-center font20">{{userInfo.dataIntegrity||0}}</view>
						<view class="t-center font13 u-6">我的资料</view>
					</view>
				</view>
				<view class="contentBox" :class="isOdd?'mar':''">
					<block v-if="isOdd">
						<view class="flex  jst-between myOddBg mT15 pT15">
							<view class="font16  mL15">
								<text class="pR5" :class="currentTab==1?'font17 bold':'font13'"
									@click="changeTab(1)">我的发布</text>
								<text class="pL15" :class="currentTab==2?'font17 bold':'font13'"
									@click="changeTab(2)">我的抢单</text>
							</view>
							<block v-if="currentTab==1">
								<view @click="xf.onlineUtils.route('/pages/companyPage/subpackge/my/myPublish/index')"
									class="u-8bd font13   mR15">查看更多 <u-icon name="arrow-right" color="#8d8d8d"
										size="24"></u-icon></view>
							</block>
							<block v-else>
								<view @click="xf.onlineUtils.route('/pages/companyPage/subpackge/my/myJob/myJob')"
									class="u-8bd font13   mR15">查看更多 <u-icon name="arrow-right" color="#8d8d8d"
										size="24"></u-icon></view>
							</block>

						</view>
						<view class="lvFlowBox flex flex-wrap bgf pT20">
							<block v-if="currentTab==1">
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.positionCount}}</view>
									<view class="t-center font13 u-6 mT10">待发布</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.releaseCount}}</view>
									<view class="t-center font13 u-6 mT10">待派工</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.hireCount}}</view>
									<view class="t-center font13 u-6 mT10">已录用</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.inProgressCount}}</view>
									<view class="t-center font13 u-6 mT10">进行中</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.settlementCount}}</view>
									<view class="t-center font13 u-6 mT10">待结算</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{fbInfo?.completeCount||0}}</view>
									<view class="t-center font13 u-6 mT10">已完成</view>
								</view>
							</block>
							<block v-else>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{grabInfo?.suggerentCount}}</view>
									<view class="t-center font13 u-6 mT10">已推荐</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{grabInfo?.hireCount}}</view>
									<view class="t-center font13 u-6 mT10">已录用</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{grabInfo?.inProgressCount}}</view>
									<view class="t-center font13 u-6 mT10">进行中</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{grabInfo?.settlementCount}}</view>
									<view class="t-center font13 u-6 mT10">待结算</view>
								</view>
								<view class="w33 mB15" @click="xf.onlineUtils.route(``)">
									<view class="t-center bold font21">{{grabInfo?.completeCount}}</view>
									<view class="t-center font13 u-6 mT10">已完成</view>
								</view>
							</block>
						</view>

					</block>
					<block v-else>
						<view class="flex  jst-between myOddBg mT15  alg-center">
							<view class="font16  mL15">
								<view class="bold">我的发布</view>
								<view class="font13 u-8bd mT5">您还未发布任何职位</view>
							</view>
							<view class="pointer bmBtn font15 mR15"
								@click="xf.onlineUtils.route(`pages/common/publishPage/index`)">立即发布</view>
						</view>
					</block>
					<view class="gzBox">
						<view class="gzh" @click="skipGzh">
							关注公众号，及时接收平台消息
						</view>
						<view class="flex alg-center pT15 pB15 pL15 pB15 mB15 myWallet" @click="xf.onlineUtils.route(`/pages/common/myWallet/index`)">
							<u-image  :width="75" :height="74" :src="resources.gold"></u-image>
							<view class="font14 mL10 u-6">我的钱包</view>
							<view  @click.stop="eyeShowChange" class="mL5">
								<u-icon v-if="eyeShow" name="eye-fill" :size="32"></u-icon>
								<u-icon v-else name="eye-off" :size="32"></u-icon>
							</view>
							<view v-if="eyeShow" class="mL10 font30">{{ balance }}</view>
							<view v-else class="mL10 font30">--</view>
						</view>
					</view>
					
					<!-- <view class="flex jst-center pT15" @click="xf.onlineUtils.route(`pages/common/publishPage/index`)">
						<u-image :width="702" :height="170" :src="resources.fbBanner" mode=""></u-image>
					</view> -->
					<swiper v-if="imgList && imgList.length" :indicator-dots="true" :autoplay="true" :vertical="false" circular :interval="2000" class="u-swiper">
						<swiper-item v-for="(item, index) in imgList" :key="index" class="u-swiper-item">
							<u-image width="100%" height="100%" :src="define.imgUrl + item.coverPicPath" mode=""></u-image>
						</swiper-item>
					</swiper>
					<view class="font18 mT15 mB15 mL12 bold">常用功能</view>
					<view class="useOptBox">
						<view class="flex flex-wrap pT15 pB15">
							<view @click="jumpUrl(item.url)" class="flex jst-center flex-v w25 mB10"
								v-for="(item,i) in navLis" :key="i">
								<image class="navImg" :src="item.icon" mode=""></image>
								<text class="t-center font13 mT10 u-6">{{item.name}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<xfCompanyTabbar></xfCompanyTabbar>
		<u-modal v-model="showCode" :show-confirm-button="false" :show-title="false" :maskCloseAble="true">
			<view class="pL15 pR15 pT15 pB15">
				<view class="t-center bold">长按识别二维码关注公众号</view>
				<view class="flex jst-center mT15 mB15" v-if="showCode">
					<image :width="200" mode="aspectFit"  :height="200" show-menu-by-longpress  :src="gzhUrl"></image>
				</view>
			</view>
		</u-modal>
	</view>
</template>

<script>
	import {
		getComOrUserInfo,
		fbStatic,
		qdStatic,
		getAdvertisement
	} from "@/api/companyInterface/user.js"
	import { changeRole, getConfigApprove, usergetOpenId, bindWx } from "@/api/common"
	import define from "@/utils/define.js"
	import { getBalance } from "@/api/companyInterface/user.js";
	export default {
		data() {
			return {
				gzhUrl: '',
				showCode:false,
				currentStep: 0,
				currentTab: 1,
				isOdd: true,
				eyeShow: false,
				fbInfo:{},
				grabInfo:{},
				grabLis: [],
				pubLis: [],
				navLis: [{
						name: '通讯录',
						url: 'pages/companyPage/subpackge/my/phoneLis/index',
						icon: this.resources.my.txl
					},
					{
						name: '切换成求职者',
						url: 'changeJober',
						icon: this.resources.my.qzz
					},
					{
						name: '保险',
						// url: 'pages/userPage/subpackge/my/myFavor/myFavor',
						icon: this.resources.my.icon5
					},
					{
						name: '我的合同',
						url: '',
						icon: this.resources.my.icon4
					},
					{
						name: '切换角色',
						url: 'pages/companyPage/subpackge/my/changeRole/index',
						icon: this.resources.my.chsf
					},
					{
						name: '我的评价',
						url: 'pages/common/myComment/index',
						icon: this.resources.my.icon10
					},
					{
						name: '我的申诉',
						url: 'pages/common/mySs/index',
						icon: this.resources.my.icon11
					},
					{
						name: '我的报名',
						url: 'pages/companyPage/subpackge/my/myBmJob/index',
						icon: this.resources.my.icon1
					},
					{
						name: '我的经纪人',
						url: '/pages/common/myBroker/index',
						icon: this.resources.my.icon13
					},
					{
						name: '开发票',
						url: '/pages/common/invoice/list/index',
						icon: this.resources.my.icon14
					},
					{
						name: '设置',
						url: '/pages/common/mySet/index',
						icon: this.resources.my.icon12
					},
				],
				timestamp: 0,
				timeData: {
					hours: 0,
					minutes: 0,
					seconds: 0
				},
				userInfo: {},
				authStatusInfo:{},
				imgList: [],
				companyId: '',
				balance: 0.00
				
			}
		},
		 onShow() {
			this.getUserInfoOpt();
			this.fbTj()
			this.qdTj()
			this.getImgList()
			let userInfo = this.xf.onlineUtils.getUserInfo()
			this.companyId = userInfo.companyId
			this.getBalanceApi()
			this.getGzhInfo()
		},
		methods: {
			getWechatLogin() { // 获取微信unionid openId方法
				uni.login({
					provider: 'weixin', // 指定授权方式为微信
					success: (res) => {
						usergetOpenId({
							type: '3', // 获取类型 网站登录订阅 1 推送订阅2 小程序3
							code: res.code
						}).then(async res => {
							bindWx({
								openId: res.result
							}).then(res=>{
							})
						});
						},
						fail: (err) => {

						}
				});
			},
			skipGzh() {
				this.showCode=true;
				this.getWechatLogin()
			},
			getGzhInfo(){
				getConfigApprove('jjp_oddjob_service').then(res=>{
					this.gzhUrl=this.define.imgUrl+res.result;
				})
			},
			getBalanceApi(){
				getBalance({}).then(res=>{
					if(res){
						const {result} = res
						this.balance = result.data
					}
				})
			},
			getImgList() {
				this.baseStore.getDictionaryDataAll('tjjjp_oddjob_wx_common').then(res => {
					if(res) {
						const value = res[0]?.value
						getAdvertisement({articleTypeId: value}).then(res=>{
							if(res){
								this.imgList = res.result
							}
						})
					}
				})
			},
			changeTab(i) {
				this.currentTab = i
			},
			eyeShowChange() {
				this.eyeShow = !this.eyeShow
			},
			getUserInfoOpt() {
				getComOrUserInfo().then(res => {
					this.userInfo = res.result;
					this.authStatusInfo=res.result.xflinggongOddUserInfoVo;
					this.userStore.setAuthStatus(this.authStatusInfo.authStatus)
					this.userStore.setUserId(this.authStatusInfo?.id);
					this.userStore.setUserInfo(JSON.stringify(this.authStatusInfo))
				})
			},
			editPage(){
				if(this.authStatusInfo.authStatus==1){
					this.xf.onlineUtils.route(`pages/companyPage/subpackge/my/myInfo/myInfo`)
				}else{
					this.xf.onlineUtils.route(`pages/userPage/subpackge/my/myInfo/myInfo`)
				}
			},
			fbTj(){
			  fbStatic({}).then(res=>{
				 this.fbInfo=res.result;
			  })
			},
			qdTj(){
				qdStatic().then(res=>{
					this.grabInfo=res.result;
				})
			},
			onChange(e) {
				this.timeData = e;
			},
			jumpUrl(url){
				if(url=='changeJober'){
					uni.navigateToMiniProgram({
					  appId: 'wx50334b07bc4c9954',
					  path: 'pages/userPage/home/index',
					  extraData: { 
					    'token': uni.getStorageSync('token')
					  },
					  success(res) {
					    console.log('打开成功');
					  }
					});
					// uni.setStorageSync('userType', 'units')
					// uni.switchTab({
					// 	url:"/pages/userPage/my/index"
					// })
				}else{
					this.xf.onlineUtils.route(url)
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		min-height: 100%;
		background: linear-gradient(0deg, #F8FAFF, #F7F8FB);
	}
</style>
<style scoped lang="scss">
	.gzBox{
		width: 100%;
		display: flex;
		margin-top: 30rpx;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}
	.gzh{
		height: 100rpx;
		width: 702rpx;
		background: linear-gradient(-12deg, #ECF2FE, #E2F0FF, #ECF2FE);
		border-radius: 30rpx 30rpx 0rpx 0rpx;
		display: flex;
		justify-content: center;
		padding: 20rpx 0 0 0;
		font-size: 26rpx;
		color: #666666;
	}
	.myWallet {
		width: 702rpx;
		margin-top: -30rpx;
		border-radius: 30rpx 30rpx 30rpx 30rpx;
		background: linear-gradient(#ffffff, #f9f9f9);
	}

	.useOptBox {
		width: 702rpx;
		margin: 0 auto;
		background: #FFFFFF;
		border-radius: 20rpx 20rpx 20rpx 20rpx;

		.navImg {
			width: 48rpx;
			height: 48rpx;
			display: block;
			margin: 10rpx auto 0 auto;
		}

	}

	.u-swiper {
		height: 176rpx;
		margin-top: 10rpx;
		padding: 0 20rpx;
	}

	.walletInfo {
		width: 702rpx;
		margin: 0 auto;
		height: 140rpx;
		// background: linear-gradient(#fff, #F8FAFF);
		border-radius: 30rpx 30rpx 30rpx 30rpx;
	}

	.bgImg {
		position: absolute;
		width: 100%;
		height: 600rpx;
		left: 0;
		top: 0;
		z-index: 0;
	}

	.noRz {
		color: #FF1414;
		border: 2rpx solid #FF1414;
		// height: 40rpx;
		line-height: 40rpx;
		border-radius: 18rpx;
		padding: 4rpx 10rpx;
		font-size: 20rpx;
		margin-left: 10rpx;
	}

	.myHeader {
		width: 120rpx;
		height: 120rpx;
		border-bottom: 20rpx;
	}

	.boxDj {
		background: linear-gradient(#ffffff, #f9f9f9);
		background-size: 100%;
		width: 702rpx;
		height: 130rpx;
		margin: 30rpx auto 0 auto;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.myOddBg {
		background: radial-gradient(#F8FAFF, #E5EBFF);
		border: 4rpx solid #fff;
		background-size: 100%;
		width: 702rpx;
		height: 140rpx;
		margin: 30rpx auto 0 auto;
		border-radius: 20rpx 20rpx 20rpx 20rpx;
	}

	.notice {
		width: 702rpx;
		margin: 0 auto;
		height: 64rpx;
		line-height: 64rpx;
		margin-top: 24rpx;
		padding: 0 20rpx;
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;

		.laba {
			width: 28rpx;
			height: 28rpx;
		}
	}

	.myZlBox {
		width: 162rpx;
		height: 54rpx;
		line-height: 54rpx;
		background: #F3FAFE;
		border-radius: 27rpx 0rpx 0rpx 27rpx;

		.zlImg {
			width: 30rpx;
			height: 30rpx;
			margin-right: 6rpx;
			margin-left: 10rpx;
		}
	}

	.contentBox {
		width: 750rpx;
		padding-bottom: 60rpx;

		.lvFlowBox {
			margin-top: -60rpx;
			margin: 0 auto;
			width: 702rpx;
			border-radius: 40rpx;
			margin-top: -40rpx;
		}
	}
</style>